<template>
  <div class="transfer-wrap">
    <lay-loading></lay-loading>
  </div>
</template>

<script lang="ts">
import { defineComponent, onMounted, reactive, ref } from "vue";
import { useRouter, useRoute } from "vue-router";
import { getUserInfo } from "@/api/module/login";
import { useSystemStore } from "@/store/login";
import{
  setAppId
} from '@/utils/core'
import { layer } from "@layui/layer-vue";

export default defineComponent({
  setup() {
    const userStore = useSystemStore();
    onMounted(async () => {
      const route = useRoute();
      const router = useRouter();
      let {
        appId,
        token
      } = route.query
      userStore.token = token;
      setAppId(appId)
      getUserInfo().then(async ({ data, timestamp, message, success }) => {
        if (success == 1) {
          userStore.token = data.token;
          userStore.systemInfo = data;
          userStore.timestamp = timestamp;
          await userStore.loadRouters();
          router.push({
            path:
              userStore.routerFrist["path"].length > 0
                ? userStore.routerFrist["path"]
                : "/error/404",
          });
        } else {
          layer.msg(message, { icon: 2 });
        }
      })
    });

    return {
    };
  },
});
</script>

